﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VRacer.Exceptions;

namespace VRacer.Client.Controls
{
    /// <summary>
    /// Interaction logic for AppException.xaml
    /// </summary>
    public partial class AppException : Window
    {
        public AppException()
        {
            InitializeComponent();
        }

        public AppException(Exception e)
            : this()
        {
            Exception innerException = e;
            while (innerException.InnerException != null && !(innerException is IUIExceptionDetail))
            {
                innerException = innerException.InnerException;
            }

            if (innerException is IUIExceptionDetail)
                DataContext = innerException;
            else
                DataContext = e;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
